<!DOCTYPE html>
<html lang="en" >
<head >
    <meta charset="utf-8" >
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" >
    <meta name="description" content="" >
    <meta name="author" content="ThemeBucket" >
    <link rel="shortcut icon" href="#" type="image/png" >

    <title >Dynamic Table</title >
    <link href="/public/js/iCheck/skins/minimal/blue.css" rel="stylesheet">

    <!--dynamic table-->
    <link href="/public/js/advanced-datatable/css/demo_page.css" rel="stylesheet" />
    <link href="/public/js/advanced-datatable/css/demo_table.css" rel="stylesheet" />
    <link rel="stylesheet" href="/public/js/data-tables/DT_bootstrap.css" />
    <?php $this->load->view('library/header'); ?>
</head >

<body class="sticky-header" >

<section >

    <?php $this->load->view('library/left'); ?>

    <!-- main content start-->
    <div class="main-content" >

        <?php $this->load->view('library/top'); ?>

        <!-- page heading start-->
        <div class="page-heading" >
            <h3 >
                产品列表 </h3 >
            <ul class="breadcrumb" >
                <li >
                    <a href="#" >Dashboard</a >
                </li >
                <li >
                    <a href="#" >Data Tables</a >
                </li >
                <li class="active" > Dynamic Table</li >
            </ul >
        </div >
        <!-- page heading end-->

        <!--body wrapper start-->
        <div class="wrapper" >
            <!--            test-->
            <div class="row" >
                <div class="col-sm-12" >
                    <?php if ($param_option):?>


<script src="/public/js/bootstrap-select-1.12.4/dist/js/bootstrap-select.min.js"></script>
<link rel="stylesheet" type="text/css" href="/public/js/bootstrap-select-1.12.4/dist/css/bootstrap-select.css" />
<link rel="stylesheet" type="text/css" href="/public/css/cate.css" />
<link rel="stylesheet" type="text/css" href="/public/css/font-awesome.min.css" />





<section class="panel">
    <header class="panel-heading">
        搜索

        <span class="tools pull-right">
            <?php if($action_link):?>
            <?php foreach ($action_link as $item) : ?>
                <a href="<?php echo $item['href'];?>" data-toggle="modal" class="btn btn-primary"><?php echo $item['name'];?></a>
            <?php endforeach;?>
            <?php endif;?>
            <a class="fa fa-refresh" href="<?php echo base_url('product/index/page/') . "?clear=1";?>"></a>
            <a class="fa fa-chevron-down" href="javascript:;"></a>
         </span>
    </header>
    <div class="panel-body" style="padding-bottom: 0;">
        <div class="row-search">
            <div class="row">
                <form action="/Product/index" method="get">
                    <?php foreach ($param_option as $k_name => $item) :?>
                        <div class="form-group <?php echo $item['col'];?>">
                            <?php if ($item['type'] == 'text') :?>
                                <input name="<?php echo $k_name;?>" value="<?php echo $param[$k_name];?>" placeholder="<?php echo $item['placeholder'];?>" type="<?php echo $item['type'];?>" class="form-control" aria-controls="dynamic-table">
                            <?php elseif ($item['type'] == 'text-c') :?>
                                <div class="input-group">
                                    <input type="text" name="<?php echo $k_name;?>" placeholder="<?php echo $item['placeholder'];?>" value="<?php echo $param[$k_name];?>" class="form-control">
                                    <div class="input-group-btn">
                                        <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown"><span class="selected"><?php echo $param[$item['item']['name']] ? $item['item']['option'][$param[$item['item']['name']]] : $item['item']['placeholder'];?></span> <span class="caret"></span></button>
                                        <input type="hidden" name="<?php echo $item['item']['name'];?>" value="<?php echo $param[$item['item']['name']];?>" />
                                        <ul class="dropdown-menu pull-right">
                                            <li><a data-id="0" href="#"><?php echo $item['item']['placeholder'];?></a></li>
                                            <?php foreach ($item['item']['option'] AS $k => $option) :?>
                                                <li><a data-id="<?php echo $k;?>" href="#"><?php echo $option;?></a></li>
                                            <?php endforeach;?>
                                        </ul>
                                    </div>
                                </div>
                            <?php elseif ($item['type'] == 'dpd_time' || $item['type'] == 'dpd'):?>
                                <div class="input-group input-large custom-date-range">
                                    <input type="text" autocomplete="off" class="form-control <?php echo $item['type'] == 'dpd_time' ? 'dpd1' : '';?>" name="<?php echo $k_name;?>_start" value="<?php echo $param[$k_name.'_start']; ?>">
                                    <span class="input-group-addon"><?php echo $item['placeholder'];?></span>
                                    <input type="text" autocomplete="off" class="form-control <?php echo $item['type'] == 'dpd_time' ? 'dpd2' : '';?>" name="<?php echo $k_name?>_end" value="<?php echo $param[$k_name.'_end']; ?>">
                                </div>
                            <?php elseif ($item['type'] == 'option') :?>
                                <select name="<?php echo $k_name;?>" class="form-control">
                                    <option value="-1"><?php echo $item['placeholder'];?></option>
                                    <?php foreach ($item['option'] as $k => $val) :?>
                                        <option <?php echo $param[$k_name] == $k ? 'selected="selected"' : '';?> value="<?php echo $k;?>"><?php echo $val;?></option>
                                    <?php endforeach;?>
                                </select>

                            <?php elseif ($item['type'] == 'option_cat') :?>

                                <select name="<?php echo $k_name;?>" class="form-control">
                                    <option>选择分类</option>

                                    <?php foreach ($item['option'] as $k => $val) :?>
                                    <?php
                                        if($val['level']==0){
                                            ?>

                                            <option class="top_cate"  <?php echo $param[$k_name] == $val['cate_id'] ? 'selected="selected"' : '';?> value="<?php echo $val['cate_id'];?>" ><?=$val['cate_name'].'('.$val['count'].')'?></option >
                                            <?php
                                        }elseif ($val['level']==1){
                                            ?>

                                            <div>
                                                <option class="" <?php echo $param[$k_name] == $val['cate_id'] ? 'selected="selected"' : '';?> value="<?php echo $val['cate_id'];?>" ><?=str_repeat('&nbsp;',$val['level']).$val['cate_name'].'('.$val['count'].')'?></option >
                                            </div>
                                            <?php
                                        }
                                        ?>

                                    <?php endforeach;?>
                                </select>
                            

                                <!-- <select name="<?php echo $k_name;?>" data-live-search-placeholder="搜索分类" data-live-search="true" class="form-control selectpicker">
                                    
                                </select> -->
                            
                            <?php elseif ($item['type'] == 'cal_option') :?>
                                
                                <select name="<?php echo $k_name;?>" class="form-control">
                                    <option value="0"><?php echo $item['placeholder'];?></option>
                                    <?php foreach ($item['option'] as $k => $val) :?>
                                        <option <?php echo $param[$k_name] == $k ? 'selected="selected"' : '';?> value="<?php echo $k;?>"><?php echo $val;?></option>
                                    <?php endforeach;?>
                                </select>
                            <?php elseif ($item['type'] == 'siteweb') :?>
                            <select name="<?php echo $k_name;?>" class="form-control">
                                <option value="0"><?php echo $item['placeholder'];?></option>
                                <?php foreach ($item['option'] as $k => $val) :?>
                                    <option <?php echo $param[$k_name] == $k ? 'selected="selected"' : '';?> value="<?php echo $k;?>"><?php echo $val;?></option>
                                <?php endforeach;?>
                            </select>
                            
                                <?php elseif ($item['type'] == 'checkbox') :?>
                                    <?php echo $item['placeholder'];?>
                                    <p>
                                    <?php foreach($item['option'] as $key => $value){ ?>

                                        <?php echo $value['type_name'];?>:
                                        <?php foreach($value['val'] as $k => $v){ ?>
                                            <input type="checkbox" value="<?php echo $v['id'];?>" name="type_style[]"><?php echo $v['type_name'];?>
                                        <?php } ?><br/>

                                    <?php } ?>
                                </p>
                            <?php endif;?>
                            
                            

                        </div>
                    
                    <?php endforeach;?>
                    <?php if($param['prepare_state']){?>
                        <input name="prepare_state" type="hidden" value="<?php echo $param['prepare_state']?>" class="form-control" aria-controls="dynamic-table">
                    <?php }?>

                    <div class="form-group col-lg-2">
                        <button class="btn btn-info" type="submit">搜索</button>
                    </div>
                </form>
            </div>
        </div>
    </div>
</section>
<?php endif;?>
<?php if ($supp_list) : ?>
<section class="panel">
    <div class="panel-body" style="padding-bottom: 0;">
        <div class="row-operate icheck">
            <div class="row">
                <?php foreach ($supp_list as $k => $val):?>
                    <div class="flat-green single-row col-lg-2">
                        <div class="radio ">
                            <input tabindex="3" value="<?php echo $k;?>" type="radio"  name="demo-radio">
                            <label><?php echo $val;?>（90） </label>
                        </div>
                    </div>
                <?php endforeach;?>
            </div>
        </div>
    </div>
</section>
<?php endif;?>
<script type="text/javascript">

    $(function () {
        $('.dropdown-menu a').click(function () {
            $(this).parents('ul').prevAll('button').find('.selected').html($(this).html());
            $(this).parents('ul').prev('input').val($(this).attr('data-id'));
        });
    });

</script>

                    <section class="panel" >
                        <div class="panel-body" >
                            <div class="adv-table" >
                                <table class="display table table-bordered table-striped" id="dynamic-table" >
                                    <thead >
                                    <tr >
                                        <th width="6%" >编号</th >
                                        <th width="10%" >图片</th >
                                        <th width="20%" >商品名称</th >
                                        <th width="10%" class="hidden-phone" >货号</th >
                                        <th width="9%" class="hidden-phone" >供货商</th >
                                        <th width="5%" class="hidden-phone" >进货价</th >
                                        <th width="5%" class="hidden-phone" >价格</th >
                                        <th width="5%" class="hidden-phone" >重量</th >
                                        <th width="10%" class="hidden-phone" >添加时间</th >
                                        <th width="5%" class="hidden-phone" >质检</th >
                                        <th width="5%" class="hidden-phone" >侵权</th >
                                        <th width="5%" class="hidden-phone" >渠道</th >
                                        <th width="5%" class="hidden-phone" >操作</th >
                                    </tr >
                                    </thead >
                                    <tbody >
                                    <?php foreach ($goods_list as $item): ?>
                                        <tr class="gradeX" >
                                            <td ><label ><input
                                                            onclick="add_cookie(this)"
                                                            class="goods_ids" <?php echo $item['export_goods'] ? 'checked' : ''; ?>
                                                            name="goods_ids[]" type="checkbox"
                                                            value="<?php echo $item['goods_id']; ?>" /><?php echo $item['goods_id']; ?>
                                                </label ></td >
                                            <td ><a href="#myModal_img" data-toggle="modal"><img class="img_list" goods_id="<?php echo $item['goods_id']; ?>"
                                                        style="width: 100px;"
                                                        src="<?php echo $item['original_img']; ?>" /></a></td ></a><!-- <a download="beautifulGirl" href="<?php echo $item['original_img']; ?>"></a> -->
                                            <td >
                                                <?php echo $item['goods_name']; ?>
                                                <br /> <span
                                                        style="color: #166aab;" ><?php echo $item['cn_name']; ?></span >
                                                <br /> 产品链接: <a
                                                        style="display: block; width: 300px;" target="_blank"
                                                        class="proce-goods"
                                                        href="<?php echo $item['supp_url']; ?>" ><?php echo $item['supp_url']; ?></a >
                                                <span style="color: #110cea;" >标签：<?php echo $item['tags'] ?></span ><br >
                                                <span style="color: #110cea;" >状态：
                                                    <?php if( $item['is_on_sale'] == 1):  ?>
                                                    上架
                                                    <?php elseif( $item['is_on_sale'] == 0):  ?>
                                                    下架
                                                    <?php elseif( $item['is_on_sale'] == 2):  ?>
                                                    部分下架
                                                    <?php endif; ?>
                                                </span >
                                                <br > 颜色：
                                                <?php foreach ($item['color'] as $v): ?>
                                                    <span ><?php echo $v; ?></span >
                                                <?php endforeach; ?>
                                                <br > 尺码：
                                                <?php foreach ($item['size'] as $v): ?>
                                                    <span ><?php echo $v; ?></span >
                                                <?php endforeach; ?>
                                            </td >
                                            <td class="center hidden-phone" >
                                                <span class="keydiv"><?php echo $item['goods_sn']; ?></span><br /> <span
                                                        style="color: #990f40;" ><?php echo $item['supp_sn']; ?></span >
                                                <?php if ($item['wou']) : ?><?php foreach ($item['wou'] as $row): ?>
                                                    <br /><span
                                                            class="btn btn-default btn-xs delete_goods_web"
                                                            goods_id="<?php echo $item['goods_id']; ?>"
                                                            web_name="<?php echo $row['web_name']; ?>"
                                                            web_id="<?php echo $row['web_id']; ?>" ><?php echo $row['web_name'] . ':' . date('Y-m-d', $row['add_time']); ?></span >
                                                <?php endforeach; endif; ?>

                                            </td >
                                            <td class="hidden-phone" ><a
                                                        target="_blank"
                                                        href="" ><?php echo $item['suppliers_name']; ?></a >
                                                <p >面料：<?php echo $item['fabric'] ?></p >
                                                <p >采购员：<?php echo $item['purchase_name'] ?></p >

                                            </td >
                                            <td class="center hidden-phone" ><?php echo $item['in_price']; ?></td >
                                            <td class="center hidden-phone" ><?php echo $item['shop_price']; ?></td >
                                            <td class="center hidden-phone" ><?php echo $item['goods_weight']; ?></td >
                                            <td class="center hidden-phone" ><?php echo date('Y-m-d', $item['add_time']); ?></td >
                                            <td class="center hidden-phone" ><?php if ($item['is_testing'] == 1){
                                                    echo '合格';
                                                } elseif ($item['is_testing'] == 2) {
                                                    echo '不合格';
                                                } else {
                                                    echo '待质检';
                                                } ?></td >
                                            <td class="center hidden-phone" ><?php echo $item['is_tort'] ? '侵权' : '不侵权'; ?></td >
                                            <td class="center hidden-phone" >

                                                <?php if ($item['channel_id'] == 1){
                                                    echo '外网';
                                                } elseif ($item['channel_id'] == 2) {
                                                    echo '竞争对手';
                                                } elseif ($item['channel_id'] == 3) {
                                                    echo '供应商1688';
                                                } ?>
                                            </td >

                                            <td class="hidden-phone" >
                                                <a
                                                        class="btn btn-xs btn-info"
                                                        href="<?php echo base_url('Product/set/goods_id/' . $item['goods_id']); ?>" >编辑</a >
                                                <a
                                                        class="btn btn-xs btn-info import-ajax"
                                                        data-sn="<?php echo $item['goods_sn']; ?>"
                                                        href="<?php echo base_url("ShopifyApi/upload_goods/goods_id/{$item['goods_id']}"); ?>" >上传</a >
                                                <a
                                                        class="btn btn-xs btn-info ueeshop-ajax"
                                                        data-sn="<?php echo $item['goods_sn']; ?>"
                                                        href="<?php echo base_url("UeeshopApi/up_product/goods_id/{$item['goods_id']}"); ?>" >上传UEE</a >
                                                <a
                                                        class="btn btn-xs btn-info tort"
                                                        data-goods_id="<?php echo $item['goods_id']; ?>" >修改侵权</a >

                                                <?php if(!empty($item['wou'])): ?>
                                                <a
                                                          class="btn btn-xs btn-info up_goods_web"
                                                          data-goods_id="<?php echo $item['goods_id']; ?>"
                                                          data-sn="<?php echo $item['goods_sn']; ?>"
                                                          href="<?php echo base_url('ShopifyApi/goods_web_up');?>" >同步更新</a >
                                                <a
                                                          class="btn btn-xs btn-info up_goods_web"
                                                          data-goods_id="<?php echo $item['goods_id']; ?>"
                                                          data-sn="<?php echo $item['goods_sn']; ?>"
                                                          href="<?php echo base_url('ShopifyApi/goods_web_img');?>" >更新图片</a >
                                                <div id="update-good-web-<?php echo $item['goods_id']; ?>" style="display: none">
                                                <select size="2" id="update-good-web-choose-<?php echo $item['goods_id']; ?>" style="width: 90%;font-size: 16px;height:150px" multiple>
                                                  <?php foreach($item['wou'] as $key => $value ):?>
                                                  <option value="<?php echo $value['web_id']; ?>"><?php echo $value['web_name']; ?></option>
                                                  <?php endforeach; ?>
                                                </select>
                                                <p style="padding: 10px;color: #f00;font-size:14px;text-align: left">请按住ctrl多选<p>

                                                </div>

                                                <?php endif; ?>
                                                <?php if ($item['goods_e_sku']){ ?>
                                                    <a
                                                            style="background: red;"
                                                            class="btn btn-xs btn-info goods_e_sku" href="#myModal"
                                                            data-toggle="modal"
                                                            data-goods_id="<?php echo $item['goods_id']; ?>" >上传E仓</a >
                                                <?php } else{ ?>
                                                      <a
                                                            style="background: red;"
                                                            class="btn btn-xs btn-info goods_e_sku_attr"
                                                            data-goods_id="<?php echo $item['goods_id']; ?>" >更新E仓规格图片</a >
                                                <?php } ?>
                                                <?php if ($item['goods_e_sku_img']){ ?>
                                                    <a
                                                            style="background: red;"
                                                            class="btn btn-xs btn-info goods_e_sku_img"
                                                            data-goods_id="<?php echo $item['goods_id']; ?>" >更新E仓图片</a >
                                                <?php } ?>


                                              <?php if($item['is_on_sale'] == 1 || $item['is_on_sale'] == 2){?>
                                                <a class="btn btn-xs btn-info off_shelve" href="#off_shelve_dialog" data-is="1" data-id="<?php echo $item['goods_id']; ?>" data-toggle="modal"  >下架</a>
                                              <?php }?><br>
                                            </td >
                                        </tr >
                                    <?php endforeach; ?>
                                    </tbody >
                                </table >
                            </div >
                            <div >
                                <td class="hidden-phone" >
                                    <a
                                            style="height: 30px;width: 103px;" class="btn btn-xs btn-info allChoose"
                                            ><span
                                        style="font-size: 17px;" >全选</span ></a >
                                    <a
                                            style="height: 30px;width: 103px;" class="btn btn-xs btn-info cancelChoose"
                                    ><span
                                            style="font-size: 17px;" >取消全选</span ></a >
                                </td >
                                <!-- <td class="hidden-phone" >
                                    <a
                                            style="height: 30px;width: 103px;" class="btn btn-xs btn-info import"
                                            data-sn="<?php echo $item['goods_sn']; ?>"
                                            href="<?php echo base_url("ShopifyApi/upload_goods/goods_id/{$item['goods_id']}"); ?>" ><span
                                                style="font-size: 17px;" >批量上传</span ></a >
                                </td > -->
                                <td class="hidden-phone" >
                                    <!--                                    分类-->
                                    <a
                                            style="height: 30px;width: 103px;" class="btn btn-xs btn-info thisURL"
                                            href="<?php echo base_url("Product/excel?goods_name=" . $_GET['goods_name'] . '&' . 'cate_name=' . $_GET['cate_name'] . '&' . 'admin_id=' . $_GET['admin_id'] . '&' . 'is_on_sale=' . $_GET['is_on_sale'] . '&' . 'siteweb=' . $_GET['siteweb'] . '&' . 'add_time_start=' . $_GET['add_time_start'] . '&' . 'add_time_end=' . $_GET['add_time_end'] . '&' . 'is_tort=' . $_GET['is_tort'] . '&' . 'is_on_sales=' . $_GET['is_on_sales']); ?>" ><span
                                                style="font-size: 17px;" >EXCEL导出</span ></a > <select
                                            class="excel_psge" name="excel_psge" >
                                        <option value="1" >1</option >
                                        <option value="2" >2</option >
                                        <option value="3" >3</option >
                                        <option value="4" >4</option >
                                        <option value="5" >5</option >
                                        <option value="6" >6</option >
                                        <option value="7" >7</option >
                                        <option value="8" >8</option >
                                        <option value="9" >9</option >
                                        <option value="10" >10</option >
                                    </select ><!-- <div hidden id="keydiv">Hello World</div> -->
                                    <a style="height: 30px;width: 103px;" class="btn btn-xs btn-info thisURL"  ><span style="font-size: 17px;" onclick="copyText()">复制货号</span ></a >
                                </td >
                            </div >
                            <div class="row-fluid" >
                                <div class="span6" >
                                    <div class="dataTables_paginate paging_bootstrap pagination" >
                                        <ul >
                                            <?php echo $pages; ?>
                                        </ul >
                                    </div >
                                </div >
                            </div >
                        </div >
                    </section >
                </div >
            </div >
        </div >
        <!--审核弹窗-->
        <div
                class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
                aria-hidden="true" >
            <div class="modal-dialog" >
                <div class="modal-content" >
                    <div class="modal-header" ><h4 class="modal-title" >审核产品sku</h4 ></div >
                    <div class="modal-body row" >
                        <table border="1px" >
                            <tr >
                                <td style="width: 100px;" >图片</td >
                                <td style="width: 200px;" >shopify尺码</td >
                                <td style="width: 200px;" >采购尺码</td >
                                <td style="width: 200px;" >shopify颜色</td >
                                <td style="width: 200px;" >采购颜色</td >
                            </tr >
                        </table >
                        <table class="aaa" >

                        </table >

                        <div class="col-md-7" >

                            <div class="pull-right" >
                                <button class="btn btn-success btn-sm goods_sku_examine" type="button" >审核</button >
                            </div >
                        </div >
                    </div >
                </div >
            </div >
        </div >
        <!--body wrapper end-->

        <!-- 下架弹框 -->
        <div aria-hidden="true" aria-labelledby="myModalLabel" role="dialog" tabindex="-1" id="off_shelve_dialog"
             class="modal fade">
          <div class="modal-dialog">
            <div class="modal-content">
              <div class="modal-header">
                <button aria-hidden="true" data-dismiss="modal" class="close" type="button">×</button>
                <h4 class="modal-title">下架产品</h4>
              </div>
              <div class="modal-body">

                <form role="form" id="commentForm">
                  <div class="form-group">
                    <label for="exampleInputEmail1" style="font-weight: 700">SKU信息</label>
                    <div class="modal-sku icheck">
                    </div>
                  </div>
                  <!--<div class="form-group">
                      <label for="exampleInputPassword1" style="font-weight: 700" >上架站点</label>
                      <div class="modal-web icheck">
                      </div>
                  </div>-->
                  <div class="form-group">
                    <label for="exampleInputPassword1" style="font-weight: 700;margin-right: 20px;">下架原因</label>
                    <div class="reason" style="width: 50%; padding-top: 10px;">
                      <select class="form-control" name="reason">
                        <option value="0">请选择</option>
                        <option value="1">缺货</option>
                        <option value="2">断货</option>
                        <option value="3">质检不合格</option>
                        <option value="4">侵权</option>
                        <option value="5">滞销</option>
                        <option value="6">预售失败</option>
                      </select>
                    </div>
                  </div>
                  <input type="hidden" name="goods_id" value=""/>
                  <button type="submit" class="btn btn-primary is_on_sale">确定</button>
                </form>
              </div>
            </div>
          </div>
        </div>


        <!--footer section start-->
        <footer >
            2014 &copy; AdminEx by
        </footer >
        <!--footer section end-->


    </div >
    <!-- main content end-->
</section >
<!--审核弹窗-->
<div class="modal fade" id="myModal_img" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header"><h4 class="modal-title">产品图片(点击下载)</h4></div>
            <div class="modal-body row aa">
                
                <img style="width: 196px;" class="t_img" src="/album/2019/11/08/eecb50f0f381665ed78b1c4e6eb517ea.jpg" alt="">
                
                    <!-- <div class="pull-right"><button class="btn btn-success btn-sm examine_one" type="button">审核</button></div> -->
            </div>
        </div>
    </div>
</div>
<script id="select-website" type="text/x-jquery-tmpl">
  <select size="2" id="choose" style="width: 90%;font-size: 16px;height:150px" multiple>
    <?php foreach($siteweb as $key => $value ):?>
    <option value="<?php echo $key; ?>"><?php echo $value; ?></option>
    <?php endforeach; ?>
  </select>
  <p style="padding: 10px;color: #f00;font-size:14px;text-align: left">请按住ctrl多选<p>
</script>

<?php $this->load->view('library/footer'); ?>
<script src="/public/js/iCheck/jquery.icheck.js"></script>
<script src="/public/js/icheck-init.js"></script>

<script type="text/javascript" >
    $('.img_list').click(function(){
        var goods_id = $(this).attr('goods_id');
        $.ajax({
            type:'post',
            url:"<?php echo base_url('Product/img_list');?>",
            dataType:'json',
            data:{
                goods_id:goods_id
            },
            success:function(msg){
                var img = '';
                $.each(msg,function(k,v){
                    img += '<a download="beautifulGirl" href="'+v.original_img+'"><img style="width: 200px;"  src="'+v.original_img+'" alt=""></a>';
                })
                $('.aa').html(img)
            }
        })
    })
    function copyText() {
        var Url2 = '';
        $('.keydiv').each(function(ii,vv){
            Url2 += ','+vv.innerText;
        })
var oInput = document.createElement('input');
oInput.value = Url2;
document.body.appendChild(oInput);
oInput.select();
document.execCommand("Copy");
oInput.className = 'oInput';
oInput.style.display = 'none';
alert('复制成功');
}
    // 全选
    $('.allChoose').click(function () {
        $('.goods_ids').attr("checked", true)
    });
    //取消全选
    $('.cancelChoose').click(function () {
        $('.goods_ids').attr("checked", false)
    });

    $ ('.goods_e_sku').click (function () {
        var goods_id = $ (this).data ('goods_id');
        $ ('.goods_sku_examine').attr ('goods_id', goods_id);
        $.ajax ({
            type: 'post',
            url: "<?php echo base_url('Product/goods_e_sku');?>",
            dataType: 'json',
            data: {
                goods_id: goods_id,
            },
            success: function (msg) {
                var aa = '';
                $.each (msg, function (k, v) {
                    aa += '<tr style="border-style:dashed;border-width:2px;">';
                    aa += '<td style="width: 100px;"><img style="width:50px;height:50px;" src="' + v.album_url + '"/></td>';
                    aa += '<td style="width: 200px;">' + v.size + '</td>';
                    aa += '<td style="width: 200px;">' + v.ali_size + '</td>';
                    aa += '<td style="width: 200px;">' + v.color + '</td>';
                    aa += '<td style="width: 200px;">' + v.ali_color + '</td>';
                    aa += '</tr>';
                })
                $ ('.aaa').html (aa);
            }
        })
    })

    // E仓图片更新
    //商品更新
    $ ('.goods_e_sku_img').click (function () {
        var _this = $ (this);
        swal ({
            title: '更新',
            showCancelButton: true,
            preConfirm: function preConfirm(value) {
                var goods_id = _this.data ('goods_id');
                swal ({
                    imageUrl: '/public/images/Forrest.gif',
                    title: '稍等...',
                    allowOutsideClick: false,
                    showConfirmButton: false
                });
                return $.post ("<?php echo base_url('Product/syncProduct_edit_img');?>", {goods_id: goods_id}, function (data) {
                    return data;
                }, 'json');
            }
        }).then (function (result) {
            if (result.value) {
                var data = result.value;
                swal ({
                    type: data.status,
                    title: data.info
                }).then (function (isConfirm) {
                    location.reload ();
                });
            }
        });
    });


    //e仓商品规格图片更新
    $ ('.goods_e_sku_attr').click (function () {
        var _this = $ (this);
        swal ({
            title: 'e仓规格图片更新',
            showCancelButton: true,
            preConfirm: function preConfirm(value) {
                var goods_id = _this.data ('goods_id');
                swal ({
                    imageUrl: '/public/images/Forrest.gif',
                    title: '稍等...',
                    allowOutsideClick: false,
                    showConfirmButton: false
                });
                return $.post ("<?php echo base_url('Product/syncProduct_attr_img');?>", {goods_id: goods_id}, function (data) {
                    return data;
                }, 'json');
            }
        }).then (function (result) {
            if (result.value) {
                var data = result.value;
                swal ({
                    type: data.status,
                    title: data.info
                }).then (function (isConfirm) {
                    location.reload ();
                });
            }
        });
    });



    $ ('.goods_sku_examine').click (function () {
        $ (this).attr ('disabled', true);
        var goods_id = $ (this).attr ('goods_id');
        var url = "<?php echo base_url('Product/goods_sku_examine'); ?>";
        swal ({
            title: '提交sku',
            allowOutsideClick: false,
            confirmButtonText: 'Submit',

            preConfirm: function preConfirm(value) {
                swal ({
                    imageUrl: '/public/images/Forrest.gif',
                    title: '稍等...',
                    allowOutsideClick: false,
                    showConfirmButton: false
                });
                return $.post (url, {goods_id: goods_id}, function (data) {
                    return data;
                }, 'json');
            }
        }).then (function (result) {
            if (result.value) {
                var data = result.value;
                swal ({
                    type: data.status,
                    title: data.info
                }).then (function (isConfirm) {
                    location.reload ();
                });
            }
        });
    })
    $ (".excel_psge").change (function () {
        var excel_psge = $ ('.excel_psge').val ();
        var href = $ ('.thisURL').attr ('href');
        var url = href + '&excel_psge=' + excel_psge;
        $ ('.thisURL').attr ('href', url);
    })
    /**
     *选择分类
     */
    $ ('select[name="cate_cat"]').change (function () {
        var result = <?php echo json_encode($cat_res);?>;

        var cat_id = $ ('select[name="cate_cat"]').val ();
        $ ('select[name="cate_name"]').empty ();
        $.each (result, function (index, value) {
            if (index == cat_id) {
                $ ('select[name="cate_name"]').append ("<option value=" + '-1' + ">" + '选择分类' + "</option>");
                $.each (value, function (i, v) {
                    console.log (v);
                    $ ('select[name="cate_name"]').append ("<option value=" + v.cate_id + ">" + v.cate_name + "</option>");
                })
            }

        })


    })
    //修改侵权 
    $ ('.tort').click (function () {
        var _this = $ (this);
        swal ({
            title: '修改侵权',
            showCancelButton: true,
            preConfirm: function preConfirm(value) {


                var goods_id = _this.data ('goods_id');
                $.ajax ({
                    type: 'post',
                    url: "<?php echo base_url('Product/tort');?>",
                    data: {
                        goods_id: goods_id,
                    },
                    success: function (s) {
                        _this.parent ('td').prev ().html (s);
                    }
                })
            }
        })
    })
    //商品更新
    $ ('.up_goods_web').click (function () {
        var url = $(this).attr ('href');
        var goods_sn = $(this).attr ('data-sn');
        var goods_id = $(this).attr ('data-goods_id');
        var web_info = $('#update-good-web-'+goods_id);
        var update_choose_id = '#update-good-web-choose-'+ goods_id + ' option:checked';
        var chooseValue = [];

        swal ({
            title: goods_sn,
            input: 'input',
            html: web_info.html(),
            showCancelButton: true,
            allowOutsideClick: false,
            confirmButtonText: 'Submit',
            inputPlaceholder: '请选择网站',
            customClass: "sweetAlert",
            inputValidator: function () {

              $(update_choose_id).each(function (key, value) {
                chooseValue[key] = value.value
              })

              if (!($(update_choose_id).val())) {
                return '未选择任何网站!';
              }
            },
            preConfirm: function preConfirm() {
                swal ({
                    imageUrl: '/public/images/Forrest.gif',
                    title: '稍等...',
                    allowOutsideClick: false,
                    showConfirmButton: false
                });

                return $.post (url, {
                  web_id : chooseValue,
                  goods_id : goods_id
                }, function (data) {
                    return data;
                }, 'json');
            }
        }).then (function (result) {
            if (result.value) {
                var data = result.value;
                swal ({
                    type: data.status,
                    title: data.info
                }).then (function (isConfirm) {
                    location.reload ();
                });
            }
        });

         return false;
    });

    //设置cookie
    function setCookie(cname, cvalue, exdays) {
        var d = new Date ();
        d.setTime (d.getTime () + (exdays * 24 * 60 * 60 * 1000));
        var expires = "expires=" + d.toUTCString ();
        document.cookie = cname + "=" + cvalue + ";path=/; " + expires;
    }

    //获取cookie
    function getCookie(cname) {
        var name = cname + "=";
        var ca = document.cookie.split (';');
        for (var i = 0; i < ca.length; i++) {
            var c = ca[ i ];
            while (c.charAt (0) == ' ') c = c.substring (1);
            if (c.indexOf (name) != -1) return c.substring (name.length, c.length);
        }
        return "";
    }

    //清除cookie
    function clearCookie(name) {
        setCookie (name, "", -1);
    }

    function add_cookie(export_goods) {
        var cgoods = getCookie ('export_goods');
        if (export_goods.checked) {
            setCookie ('export_goods', (cgoods ? (cgoods + ',') : '') + export_goods.value, 1);
        }
        else {
            arr_goods = cgoods.split (',');
            for (i in arr_goods) {
                if (arr_goods[ i ] == export_goods.value) {
                    arr_goods.shift (i, 1);
                }
            }
            setCookie ('export_goods', arr_goods.join (','), 1);
        }
    }

    $ ('.ueeshop-ajax').on ("click", function () {

        var url = $ (this).attr ('href');

        var goods_sn = $ (this).attr ('data-sn');

        $.get (url, function (data) {

            swal ({
                title: goods_sn,
                html: data,
                showCancelButton: true,
                confirmButtonText: 'Submit',
                showLoaderOnConfirm: true,
                preConfirm: function preConfirm() {
                    return $.post (url, {
                        web_id: $ ('#a_web_id option:selected').val (),
                        cate_id: $ ('#a_cate_id').val ()
                    }, function (data) {
                        return data;
                    }, 'json');
                },
                allowOutsideClick: false
            }).then (function (result) {
                console.log (result);
                if (result.value) {
                    var data = result.value;
                    swal ({
                        type: data.status,
                        title: data.info
                    }).then (function (isConfirm) {
                        location.reload ();
                    });
                }
            });

        }, 'html');

        return false;
    });

    $ ('body').on ('change', '#a_web_id', function () {
        var web_id = $ ('#a_web_id option:selected').val ();
        var cate = $.parseJSON ($ ('#web_' + web_id).val ());

        var html = '';
        for (x in cate) {
            html += '<option value="' + cate[ x ][ 'ID' ] + '">' + cate[ x ][ 'Name' ] + '</option>';
        }
        $ ('#a_cate_id').append (html);

    });

    $ (".import-ajax").on ("click", function () {

        var url = $ (this).attr ('href');

        var goods_sn = $ (this).attr ('data-sn');

        var chooseValue = [];
        swal ({
            title: goods_sn,
            input: 'input',
            html: $('#select-website').html(),
            inputOptions: <?php echo $siteweb_json; ?>,
            showCancelButton: true,
            allowOutsideClick: false,
            confirmButtonText: 'Submit',
            inputPlaceholder: '请选择网站',
            customClass: "sweetAlert",
            inputValidator: function () {
                chooseValue = $('#choose').val()
                if (!($('#choose').val().length)) {
                    return '未选择任何网站!';
                }
            },
            preConfirm: function preConfirm() {
                swal ({
                    imageUrl: '/public/images/Forrest.gif',
                    title: '稍等...',
                    allowOutsideClick: false,
                    showConfirmButton: false
                });

                var data = {};
                $.each(chooseValue,function(index,value){
                    data[index] = value
                });

                return $.post (url, {web_id : data}, function (data) {
                    return data;
                }, 'json');
            }
        }).then (function (result) {
            if (result.value) {
                var data = result.value;
                swal ({
                    type: data.status,
                    title: data.info
                }).then (function (isConfirm) {
                    location.reload ();
                });
            }
        });

        return false;
    });


    /*
     *孙坚 
     *2019/4/13
     *产品列表批量上传
     */
    $ (".import").on ("click", function () {
        var cgoods = getCookie ('export_goods');
        swal ({
            title: '选中的全部',
            input: 'select',
            inputOptions: <?php echo $siteweb_json; ?>,
            showCancelButton: true,
            allowOutsideClick: false,
            confirmButtonText: 'Submit',
            inputPlaceholder: '请选择网站',
            inputValidator: function (value) {
                if (!value) {
                    return '未选择任何网站!';
                }
            },
            preConfirm: function preConfirm(value) {

                swal ({
                    imageUrl: '/public/images/Forrest.gif',
                    title: '稍等...',
                    allowOutsideClick: false,
                    showConfirmButton: false
                });
                return $.post ("<?php echo base_url('ShopifyApi/upload_goods_batch');?>", {
                    web_id: value,
                    cgoods: cgoods
                }, function (data) {
                    if (data.status == 'success') {
                        setCookie ('export_goods', "", -1);
                    }

                    return data;
                }, 'json');
            }
        }).then (function (result) {
            if (result.value) {
                var data = result.value;
                swal ({
                    type: data.status,
                    title: data.info
                }).then (function (isConfirm) {
                    location.reload ();
                });
            }
        });

        return false;
    });

    $ ('.bigcom').click (function () {

        var goods_sn = $ (this).data ('sn');
        var goods_id = $ (this).data ('id');

        var url = "<?php echo base_url('BigcommerceApi/bigcommerce_add/goods_id/"+goods_id+"'); ?>";
        swal ({
            title: goods_sn,
            input: 'select',
            inputOptions: <?php echo $bigcom_siteweb; ?>,
            showCancelButton: true,
            allowOutsideClick: false,
            confirmButtonText: 'Submit',
            inputPlaceholder: '请选择网站',
            inputValidator: function (value) {
                if (!value) {
                    return '未选择任何网站!';
                }
            },
            preConfirm: function preConfirm(value) {
                swal ({
                    imageUrl: '/public/images/Forrest.gif',
                    title: '稍等...',
                    allowOutsideClick: false,
                    showConfirmButton: false
                });
                return $.post (url, {web_id: value}, function (data) {
                    return data;
                }, 'json');
            }
        }).then (function (result) {
            if (result.value) {
                var data = result.value;
                swal ({
                    type: data.status,
                    title: data.info
                }).then (function (isConfirm) {
                    location.reload ();
                });
            }
        });

        return false;
    })

    $ (".delete_goods_web").on ("click", function () {
        var web_id = $ (this).attr ('web_id');
        var web_name = $ (this).attr ('web_name');
        var goods_id = $ (this).attr ('goods_id');
        var url = "<?php echo base_url('Product/shopify_goods_delete'); ?>";
        swal ({
            title: '确定要删除' + web_name + '吗?',
            showCancelButton: true,
            allowOutsideClick: false,
            confirmButtonText: 'Submit',

            preConfirm: function preConfirm(value) {
                swal ({
                    imageUrl: '/public/images/Forrest.gif',
                    title: '稍等...',
                    allowOutsideClick: false,
                    showConfirmButton: false
                });
                return $.post (url, {web_id: web_id, goods_id: goods_id}, function (data) {
                    return data;
                }, 'json');
            }
        }).then (function (result) {
            if (result.value) {
                var data = result.value;
                swal ({
                    type: data.status,
                    title: data.info
                }).then (function (isConfirm) {
                    location.reload ();
                });
            }
        });
        return false;
    });


    $('.off_shelve').on('click', function () {
        var id = $(this).attr('data-id');
        var is = $(this).data('is');
        $('.is_on_sale').attr('is_on_sale',is);

        $('input[name="goods_id"]').val(id);
        $('.icheck').html('');

        $.get('<?php echo base_url('Product/off_shelve/goods_id/');?>'+id, function (data) {

            if (data.status == 'success') {
              console.log(333333);

                var sku_list = data.data.sku_list;
                var sku_html = '';
                for (x in sku_list) {
                    sku_html += '<div class="minimal-blue single-row"><div class="checkbox "><input name="sku[]" value="'+sku_list[x].sku_id+'" type="checkbox" ' + (sku_list[x].is_on_sale == 1 ? 'checked' : '') + '><label title="' + sku_list[x].color + ' / ' + sku_list[x].size + '">' + sku_list[x].sku_sn + '</label></div></div>';
                }
                // $('.modal-sku').css('margin-left', '20px')
                // $('.modal-sku label').css('margin-right', '20px')
                $('.modal-sku').html(sku_html+'<div class="clear"></div>');

                /*var web_list = data.data.web_list;
                var web_html = '';
                for (x in web_list) {
                    web_html += '<div class="minimal-blue single-row"><div class="checkbox "><input name="web[]" value="'+web_list[x].sg_id+'" type="checkbox" ' + (web_list[x].is_sales == 1 ? 'checked' : '') + '><label>' + web_list[x].web_name + '</label></div></div>';
                }
                $('.modal-web').html(web_html+'<div class="clear"></div>');*/

                $('.icheck input').iCheck({
                    checkboxClass: 'icheckbox_minimal-blue',
                    radioClass: 'iradio_minimal-blue',
                    increaseArea: '20%',
                    labelHover: true,
                });

            } else {
console.log(22222);
                swal({
                    title: data.info,
                    text: '2秒后关闭',
                    type: data.status,
                    allowOutsideClick: false,
                    timer: data.stop ? data.stop : 1500,
                    showConfirmButton: false
                }).then(function(isConfirm) {
                    location.reload();
                });
            }

        },'json');
    })

    $('#commentForm').submit(function () {
      var id = $(this).data('is');
      var is_on_sale = $('.is_on_sale').attr('is_on_sale');

      if (is_on_sale == 1) {
        var url = '<?php echo base_url('Product/off_shelve/');?>';
      } else {
        var url = '<?php echo base_url('Product/open_shelve/');?>';
      }
      t = setTimeout(function () {
        $('#commentForm .btn-primary').attr('disabled', 'disabled').addClass('btn-submit-disabled').html('正在提交，请稍等...');
      }, 200);

      var data = new FormData(this);
      $.ajax({
        type: 'POST',
        url: url,
        data: data,
        success: function (data) {
          clearTimeout(t);
          swal({
            title: data.info,
            text: '2秒后关闭',
            type: data.status,
            allowOutsideClick: false,
            timer: data.stop ? data.stop : 1500,
            showConfirmButton: false
          }).then(function (isConfirm) {
            location.reload();
          });
        },
        dataType: 'json',
        cache: false,
        contentType: false,
        processData: false
      });

      return false;
    })

</script >

<!--dynamic table-->
<!--<script type="text/javascript" language="javascript" src="/public/js/advanced-datatable/js/jquery.dataTables.js"></script>-->
<!--<script type="text/javascript" src="/public/js/data-tables/DT_bootstrap.js"></script>-->
<!--dynamic table initialization -->
<!--<script src="/public/js/dynamic_table_init.js"></script>-->

<!--common scripts for all pages-->
<script src="/public/js/scripts.js" ></script >

</body >
</html >
<style>
    .sweetAlert {
        width: 400px;
        height: 300px;
        padding: 20px;
    }
</style>
